/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 sagyf Yang. The Four Group.
 */

package app.models.gift;

import app.models.DaoKit;
import com.github.sog.annotation.TableBind;
import com.github.sog.controller.datatables.core.DatatablesCriterias;
import com.github.sog.plugin.sqlinxml.SqlKit;
import com.google.common.collect.Lists;
import com.jfinal.plugin.activerecord.Model;

import java.util.List;

/**
 * <p>
 * .
 * </p>
 *
 * @author sagyf yang
 * @version 1.0 2014-05-27 22:34
 * @since JDK 1.6
 */
@TableBind(tableName = "ol_gift")
public class Gift extends Model<Gift> {
    /**
     * The public dao.
     */
    public static final  Gift dao              = new Gift();
    private static final long serialVersionUID = 5731575593076849376L;

    public List<Gift> findByStatus(boolean status) {
        return find(SqlKit.sql("gift.findByStatus"), status);
    }

    public com.jfinal.plugin.activerecord.Page<com.jfinal.plugin.activerecord.Record> datatable(DatatablesCriterias criterias, String filter_code, String filter_name) {
        List<Object> params = Lists.newArrayList();
        params.add(DaoKit.like(filter_code));
        params.add(DaoKit.like(filter_name));
        return DaoKit.paginate("gift", criterias, params);
    }

    public boolean batch_stop(List<String> ids) {
       return DaoKit.batch_update_by_id(SqlKit.sql("gift.batch_stop"), ids);
    }

    public boolean batch_start(List<String> ids) {
        return DaoKit.batch_update_by_id(SqlKit.sql("gift.batch_start"), ids);
    }
}